package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 日报表
 */
@Setter
@Getter
public class Daily extends BaseDomain {
    public static final int STATE_ENABLE = 1;//启用
    public static final int STATE_DISABLE = 0;//禁用

    private String title;//标题

    private String subTitle;//副标题

    private String coverUrl;//封面

    private int state;//状态

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;//创建时间

    private DailyContent dailyContent;//文章内容对象

    //获取json数据
    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        return JSONUtil.toJSONString(map);
    }
}